package com.sangengblog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sangengblog.domain.entity.ArticleTag;
import com.sangengblog.mapper.ArticleTagMapper;
import com.sangengblog.service.ArticleTagService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 三更  B站： https://space.bilibili.com/663528522
 */
@Service
public class ArticleTagServiceImpl extends ServiceImpl<ArticleTagMapper, ArticleTag> implements ArticleTagService {
    @Override
    public Long[] listByArticleId(Long id) {
        LambdaQueryWrapper<ArticleTag> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ArticleTag::getArticleId, id);
        List<ArticleTag> list = list(queryWrapper);

        Long[] tagIdsLongArray = list.stream()
                .map(ArticleTag::getTagId) // 假设getTagId返回Long
                .toArray(Long[]::new);
        return tagIdsLongArray;
    }
}
